#!/usr/bin/python3

# This script downloads Android malware (and goodware) from andrototal.org

import subprocess
import os
import glob
from configparser import ConfigParser

def main():
    config = ConfigParser()
    config.read('config.ini')
    API_KEY = config.get('AMA', 'API_KEY')
    START_DATE = config.get('AMA', 'START_DATE')
    END_DATE = config.get('AMA', 'END_DATE')
    subprocess.check_call('./tools/samples_cli.py getbydate -at-key {} {} {}'.format(API_KEY, START_DATE, END_DATE), shell=True)
    for apk in glob.glob('*.apk'):
       os.rename(apk, 'all_apks/' + apk)

if __name__=='__main__':
    main()
